<{include file="Public/head.tpl"}>
<{include file="Public/header.tpl"}>
<{include file="Public/siderbar.tpl"}>
<{include file="Public/contentheader.tpl"}>
	<section class="content">
		
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <button  class="btn btn-warning btn-flat" onclick="backup(this);">备份</button>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <table class="bootstrap-table table">
                            <thead>
                                <tr>
                                    <th data-field="id" data-align="left">备份文件名</th>
                                    <th data-field="operate" data-align="center">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                            <{foreach $sqlArr as $key=>$sql}>
                            	<tr>
                            		<td><{$sql}></td>
                            		<td>
                            			<button class="btn btn-primary btn-flat" num="<{$key}>" onclick="restore(this);">还原</button>
                            			<button class="btn btn-primary btn-flat" num="<{$key}>" onclick="del(this);">删除</button>
                            		</td>
                            	</tr>
                            <{/foreach}>
                            </tbody>
                        </table>
                    </div>
                    <!-- /.box-body -->
                </div>
                <!-- /.box -->
            </div>
            <!-- /.col -->
        </div>
	</section>
</div>
  
<{include file="Public/footer.tpl"}>
<script>
    function backup(o) {
		bootbox.setLocale("zh_CN");
	    var posturl = window.location.href;
	    $(o).attr("disabled","disabled");
		$.ajax({
			url : posturl,
			type : 'post',
			data : 'operate=backup',
			success : function(data) {
				var ret = JSON.parse(data);		
				bootbox.alert(ret.data);
				$(o).removeAttr("disabled");
				window.location.href = posturl;	
			}
		});
	}
	
	function restore(o) {
	   	bootbox.setLocale("zh_CN");
	    var posturl = window.location.href;
	   	var num = $(o).attr('num');
	   	$("button:contains('还原')").attr("disabled","disabled");
		$.ajax({
			url : posturl,
			type : 'post',
			data : 'num=' + num,
			success : function(data) {
				var ret = JSON.parse(data);		
				bootbox.alert(ret.data);
				$("button:contains('还原')").removeAttr("disabled");	
			}
		});
	}
	
	function del(o) {
	   	bootbox.setLocale("zh_CN");
	    var posturl = "/admin/sys/del";
	   	var num = $(o).attr('num');
		$.ajax({
			url : posturl,
			type : 'post',
			data : 'num=' + num,
			success : function(data) {
				var ret = JSON.parse(data);		
				bootbox.alert(ret.data);
				window.location.href = "/admin/sys/db";	
			}
		});
	}
	
</script>
</body>
</html>